package com.asia5b.a5mall.middleware.model.order

import android.text.TextUtils
import com.asia5b.a5bmall.resource.ResString
import com.asia5b.a5mall.middleware.R
import com.asia5b.a5mall.middleware.model.bean.OrderStatusType
import com.asia5b.a5mall.middleware.model.bean.CommentMultiItemEntity
import com.asia5b.a5mall.middleware.model.bean.MenuBean
import com.asia5b.a5mall.middleware.model.shop.AbsGoodsModel
import com.google.gson.annotations.SerializedName
import java.io.Serializable

/**
 * Created by zhangyuncai on 2020/1/13.
 */
open class OrderDetailModel : Serializable, CommentMultiItemEntity() {

    /*后期添加*/
    fun notifyChecked(): Boolean {
        var checkedsum = 0
        var sum = 0
        sent_parcel?.forEach {
            if (it.checked && it.isCanParcel) {
                checkedsum += 1
            }
            if (it.isCanParcel) {
                sum += 1
            }
        }
        checked = (sum != 0 && (checkedsum == sum))
        return checked
    }

    private var checked = false

    //包裹列表能否申请打包
    var isCanParcel = false
        get() {
            var canParcelSum = 0
            sent_parcel?.forEach {
                if (it.isCanParcel) {
                    canParcelSum += 1
                }
            }
            return canParcelSum > 0
        }

    //店铺id
    var seller_id = 0

    //店铺名称
    var seller_name = ""


    //订单id
    open var order_id = 0

    //订单号
    var sn = ""


    //支付方式
    var payment_type = "ONLINE"


    //支付状态
    var pay_status = "PAY_YES" //PAY_YES已付款 ,PAY_NO未付款



    //再次评论状态
    var comment_status = ""


    //支付时间
    var payment_time = 0L

    //订单创建时间
    var create_time = 0L

    //支付金额
    var pay_money = 0.0
    var pay_money_list: HashMap<String, Double>? = null

    //需要支付的支付金额
    var need_pay_money = 0.0
    var need_pay_money_list: HashMap<String, Double>? = null

    //订单总价
    @SerializedName(value = "order_price", alternate = ["order_amount"])
    open var order_price = 0.0

    @SerializedName(value = "order_price_list", alternate = ["order_amount_list"])
    open var order_price_list: HashMap<String, Double>? = null

    //商品总价
    var goods_price = 0.0
    var goods_price_list: HashMap<String, Double>? = null

    //本地运费
    var shipping_price = 0.0
    var shipping_price_list: HashMap<String, Double>? = null

    //国际运费
    var international_price = 0.0
    var international_price_list: HashMap<String, Double>? = null

    //优惠券折扣
    var coupon_price = 0.0
    var coupon_price_list: HashMap<String, Double>? = null

    //送货时间
    var receive_time = ""


    //快递公司
    var logi_name = ""


    //发货方式
    var fast_name = ""


    //仓库状态码
    private var order_status_text = ""

    //仓库状态码对应的文字,由自己另外判断
    open var order_status_text_text = ""
        get() {
            if (TextUtils.isEmpty(field)) {
                for (value in OrderStatusType.values()) {
                    if (value.statusValue == order_status_text) {
                        field = ResString.get(value.statusText)
                        break
                    }
                }
            }
            return field
        }

    var ship_time = 0

    //收货人
    var ship_name = ""


    //收货人手机号
    var ship_mobile = ""


    //收货国家
    @SerializedName(value = "shipCountry", alternate = ["ship_province"])
    var shipCountry = ""


    //收货州
    @SerializedName(value = "shipProvince", alternate = ["ship_city"])
    var shipProvince = ""


    //收货城市
    @SerializedName(value = "shipCity", alternate = ["ship_county"])
    var shipCity = ""


    //收货详细地址
    @SerializedName(value = "shipAddressDetail", alternate = ["ship_addr"])
    var shipAddressDetail = ""


    //拼接地址
    var address = ""
        get() {
            return "$shipCountry $shipProvince $shipCity $shipAddressDetail"
        }


    @SerializedName(value = "order_sku_list", alternate = ["sku_list"])
    open var order_sku_list: ArrayList<AbsGoodsModel>? = null

    //打包列表
    var sent_parcel: ArrayList<ParcelModel>? = null

    var order_operate_allowable_vo: OrderActionModel? = null
    fun getActionList(): ArrayList<MenuBean> {
        var actionList = arrayListOf<MenuBean>()
        actionList.addAll(order_operate_allowable_vo?.getActionList() ?: arrayListOf())
        if (TextUtils.equals(comment_status, "WAIT_CHASE")) {//蓝色
            actionList.add(MenuBean(1, "common_again", ResString.get(R.string.追加评论2)))
        }
        for (menuBean in actionList) {
            if (TextUtils.equals(menuBean.name, "check_logis")) {//物流还有判断条件的
                if (TextUtils.equals(ship_status, "SHIP_NO")) {
                    actionList.remove(menuBean)
                    break
                }
            }
        }
        return actionList
    }


    var desStar = 5

    /**描述相符*/
    var logisticsStar = 5

    /**物流相符*/
    var serviceStar = 5

    //备注
    var remark = ""


    var payment_num = 1 //1:一次付款 2:二次付款

    var ship_status = ""


    /**服务相符*/


}

/*
{
"order_id": 1976,
"trade_sn": "20200111000009",
"sn": "20200111000010",
"seller_id": 64,
"seller_name": "全广州最靓的店",
"member_id": 2,
"member_name": "javashop",
"order_status": "CKENTER",
"pay_status": "PAY_YES",
"ship_status": "SHIP_YES",
"shipping_id": 0,
"comment_status": "UNFINISHED",
"shipping_type": null,
"payment_method_id": null,
"payment_plugin_id": "asia5bPayPlugin",
"payment_method_name": "支付系统",
"payment_type": "ONLINE",
"payment_time": 1578726326,
"pay_money": 4604.37,
"pay_money_list": {
    "price_rmb": 4604.37,
    "price_myr": 2724.87,
    "price_thb": 19734.33,
    "price_idr": 9180211.32,
    "price_vnd": 1.518039241E7,
    "price_php": 33030.37
},
"ship_name": "test",
"ship_addr": "test address",
"ship_zip": null,
"ship_mobile": "13912341234",
"gr": "60",
"ship_tel": null,
"receive_time": "任意时间",
"ship_province_id": 53112,
"ship_city_id": 55675,
"ship_county_id": 56104,
"ship_town_id": 0,
"ship_province": "马来西亚（Malaysia）",
"ship_city": "Pahang",
"ship_county": "Balok",
"ship_town": "",
"order_price": 4604.37,
"order_price_list": {
    "price_rmb": 4604.37,
    "price_myr": 2724.87,
    "price_thb": 19734.33,
    "price_idr": 9180211.32,
    "price_vnd": 1.518039241E7,
    "price_php": 33030.37
},
"goods_price": 230,
"goods_price_list": {
    "price_rmb": 230,
    "price_myr": 136.11,
    "price_thb": 985.78,
    "price_idr": 458574.92,
    "price_vnd": 758299.24,
    "price_php": 1649.95
},
"shipping_price": 0,
"shipping_price_list": {
    "price_rmb": 0,
    "price_myr": 0,
    "price_thb": 0,
    "price_idr": 0,
    "price_vnd": 0,
    "price_php": 0
},
"discount_price": 0,
"discount_price_list": {
    "price_rmb": 0,
    "price_myr": 0,
    "price_thb": 0,
    "price_idr": 0,
    "price_vnd": 0,
    "price_php": 0
},
"international_price": 4.37,
"international_price_list": {
    "price_rmb": 4.37,
    "price_myr": 2.59,
    "price_thb": 18.73,
    "price_idr": 8712.92,
    "price_vnd": 14407.69,
    "price_php": 31.35
},
"disabled": 0,
"weight": 12,
"goods_num": null,
"remark": null,
"cancel_reason": null,
"the_sign": null,
"items_json": "[{\"item_id\":null,\"seller_id\":64,\"seller_name\":\"全广州最靓的店\",\"g
ull,\"big\":null,\"small\":null,\"thumbnail\":null,\"tiny\":null,\"spec_type\":null,\"
"warehouse_id": 11,
"need_pay_money": 4604.37,
"need_pay_money_list": {
    "price_rmb": 4604.37,
    "price_myr": 2724.87,
    "price_thb": 19734.33,
    "price_idr": 9180211.32,
    "price_vnd": 1.518039241E7,
    "price_php": 33030.37
},
"ship_no": "a5bmall15787268454,a5bmall15787265863",
"address_id": 124,
"admin_remark": null,
"logi_id": "0,0",
"logi_name": "商城快递,商城快递",
"complete_time": null,
"create_time": 1578726316,
"signing_time": null,
"ship_time": 1578726851,
"pay_order_no": "2020011110001825776610",
"service_status": "NOT_APPLY",
"bill_status": null,
"bill_sn": null,
"client_type": "PC",
"need_receipt": 0,
"order_type": "normal",
"order_data": null,
"country_id": 12,
"fasttype": 10360,
"actual_currency_short": "RMB",
"actual_amount": 10580,
"order_source": "SHOPPINGMALL",
"payment_num": 1,
"order_operate_allowable_vo": {
    "allow_cancel": false,
    "allow_confirm": false,
    "allow_pay": false,
    "allow_ship": false,
    "allow_rog": false,
    "allow_comment": false,
    "allow_complete": false,
    "allow_apply_service": false,
    "allow_service_cancel": false,
    "allow_check_express": true,
    "allow_edit_consignee": false,
    "allow_edit_price": false
},
"order_status_text": "仓库已入库",
"pay_status_text": "已付款",
"ship_status_text": "已发货",
"service_status_text": "未申请",
"payment_name": null,
"order_sku_list": [
    {
        "item_id": null,
        "seller_id": 64,
        "seller_name": "全广州最靓的店",
        "goods_id": 8475,
        "sku_id": 25147,
        "sku_sn": "ABC003",
        "cat_id": 698,
        "num": 5,
        "goods_weight": 1.2,
        "original_price": 22,
        "original_price_list": {
            "price_rmb": 22,
            "price_myr": 13.02,
            "price_thb": 94.29,
            "price_idr": 43863.69,
            "price_vnd": 72532.97,
            "price_php": 157.82
        },
        "purchase_price": 22,
        "purchase_price_list": {
            "price_rmb": 22,
            "price_myr": 13.02,
            "price_thb": 94.29,
            "price_idr": 43863.69,
            "price_vnd": 72532.97,
            "price_php": 157.82
        },
        "subtotal": 2200,
        "subtotal_list": {
            "price_rmb": 2200,
            "price_myr": 1301.96,
            "price_thb": 9429.2,
            "price_idr": 4386368.8,
            "price_vnd": 7253297.04,
            "price_php": 15782.14
        },
        "name": "库存第二十一次测试",
        "goods_image": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/6CAD4428C
        "spec_list": [
            {
                "spec_id": 2659,
                "spec_value": "粉红色",
                "seller_id": null,
                "spec_name": "Colour",
                "sku_id": null,
                "big": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/D1ABF5D46
                "small": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/D1ABF5D
                "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/D1A
                "tiny": null,
                "spec_type": 1,
                "spec_image": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/D1
                "spec_value_id": 10260
            },
            {
                "spec_id": 2660,
                "spec_value": "750ml (1 套 = 20 件)",
                "seller_id": null,
                "spec_name": "Volume &amp; Pack",
                "sku_id": null,
                "big": null,
                "small": null,
                "thumbnail": null,
                "tiny": null,
                "spec_type": null,
                "spec_image": "",
                "spec_value_id": 10264
            },
            {
                "spec_id": 2661,
                "spec_value": "送白色布袋 + 吸管",
                "seller_id": null,
                "spec_name": "Fee Gift",
                "sku_id": null,
                "big": null,
                "small": null,
                "thumbnail": null,
                "tiny": null,
                "spec_type": null,
                "spec_image": "",
                "spec_value_id": 10262
            }
        ],
        "point": null,
        "snapshot_id": 2866,
        "service_status": "NOT_APPLY",
        "single_list": [],
        "group_list": [],
        "goods_operate_allowable_vo": {
            "allow_apply_service": false
        },
        "promotion_tags": [],
        "purchase_num": 0,
        "actual_pay_total": 2200,
        "actual_pay_total_list": {
            "price_rmb": 2200,
            "price_myr": 1301.96,
            "price_thb": 9429.2,
            "price_idr": 4386368.8,
            "price_vnd": 7253297.04,
            "price_php": 15782.14
        },
        "units_number": 25,
        "total_number": 125,
        "sn": null,
        "enable_quantity": 0,
        "traits": false,
        "traits_name": "正常"
    },
    {
        "item_id": null,
        "seller_id": 64,
        "seller_name": "全广州最靓的店",
        "goods_id": 8475,
        "sku_id": 25149,
        "sku_sn": "ABC005",
        "cat_id": 698,
        "num": 5,
        "goods_weight": 1.2,
        "original_price": 24,
        "original_price_list": {
            "price_rmb": 24,
            "price_myr": 14.2,
            "price_thb": 102.86,
            "price_idr": 47851.3,
            "price_vnd": 79126.88,
            "price_php": 172.17
        },
        "purchase_price": 24,
        "purchase_price_list": {
            "price_rmb": 24,
            "price_myr": 14.2,
            "price_thb": 102.86,
            "price_idr": 47851.3,
            "price_vnd": 79126.88,
            "price_php": 172.17
        },
        "subtotal": 2400,
        "subtotal_list": {
            "price_rmb": 2400,
            "price_myr": 1420.32,
            "price_thb": 10286.4,
            "price_idr": 4785129.6,
            "price_vnd": 7912687.68,
            "price_php": 17216.88
        },
        "name": "库存第二十一次测试",
        "goods_image": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/6CAD4428C
        "spec_list": [
            {
                "spec_id": 2659,
                "spec_value": "粉红色",
                "seller_id": null,
                "spec_name": "Colour",
                "sku_id": null,
                "big": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/D1ABF5D46
                "small": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/D1ABF5D
                "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/D1A
                "tiny": null,
                "spec_type": 1,
                "spec_image": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/D1
                "spec_value_id": 10260
            },
            {
                "spec_id": 2660,
                "spec_value": "800ml (1 套 = 20 件)",
                "seller_id": null,
                "spec_name": "Volume &amp; Pack",
                "sku_id": null,
                "big": null,
                "small": null,
                "thumbnail": null,
                "tiny": null,
                "spec_type": null,
                "spec_image": "",
                "spec_value_id": 10265
            },
            {
                "spec_id": 2661,
                "spec_value": "送白色布袋 + 吸管",
                "seller_id": null,
                "spec_name": "Fee Gift",
                "sku_id": null,
                "big": null,
                "small": null,
                "thumbnail": null,
                "tiny": null,
                "spec_type": null,
                "spec_image": "",
                "spec_value_id": 10262
            }
        ],
        "point": null,
        "snapshot_id": 2867,
        "service_status": "NOT_APPLY",
        "single_list": [],
        "group_list": [],
        "goods_operate_allowable_vo": {
            "allow_apply_service": false
        },
        "promotion_tags": [],
        "purchase_num": 0,
        "actual_pay_total": 2400,
        "actual_pay_total_list": {
            "price_rmb": 2400,
            "price_myr": 1420.32,
            "price_thb": 10286.4,
            "price_idr": 4785129.6,
            "price_vnd": 7912687.68,
            "price_php": 17216.88
        },
        "units_number": 25,
        "total_number": 125,
        "sn": null,
        "enable_quantity": 0,
        "traits": false,
        "traits_name": "正常"
    }
],
"inedita_list": [],
"send_list": [
    {
        "express_sn": "a5bmall15787265863",
        "express_name": "商城快递",
        "send_list": [
            {
                "item_id": null,
                "seller_id": 64,
                "seller_name": "全广州最靓的店",
                "goods_id": 8475,
                "sku_id": 25147,
                "sku_sn": "ABC003",
                "cat_id": 698,
                "num": 5,
                "goods_weight": 1.2,
                "original_price": 22,
                "original_price_list": {
                    "price_rmb": 22,
                    "price_myr": 13.02,
                    "price_thb": 94.29,
                    "price_idr": 43863.69,
                    "price_vnd": 72532.97,
                    "price_php": 157.82
                },
                "purchase_price": 22,
                "purchase_price_list": {
                    "price_rmb": 22,
                    "price_myr": 13.02,
                    "price_thb": 94.29,
                    "price_idr": 43863.69,
                    "price_vnd": 72532.97,
                    "price_php": 157.82
                },
                "subtotal": 2200,
                "subtotal_list": {
                    "price_rmb": 2200,
                    "price_myr": 1301.96,
                    "price_thb": 9429.2,
                    "price_idr": 4386368.8,
                    "price_vnd": 7253297.04,
                    "price_php": 15782.14
                },
                "name": "库存第二十一次测试",
                "goods_image": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/6
                "spec_list": [
                    {
                        "spec_id": 2659,
                        "spec_value": "粉红色",
                        "seller_id": null,
                        "spec_name": "Colour",
                        "sku_id": null,
                        "big": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/D
                        "small": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\
                        "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg\/20200
                        "tiny": null,
                        "spec_type": 1,
                        "spec_image": "http:\/\/47.88.173.86:82\/testShopImg\/2020
                        "spec_value_id": 10260
                    },
                    {
                        "spec_id": 2660,
                        "spec_value": "750ml (1 套 = 20 件)",
                        "seller_id": null,
                        "spec_name": "Volume &amp; Pack",
                        "sku_id": null,
                        "big": null,
                        "small": null,
                        "thumbnail": null,
                        "tiny": null,
                        "spec_type": null,
                        "spec_image": "",
                        "spec_value_id": 10264
                    },
                    {
                        "spec_id": 2661,
                        "spec_value": "送白色布袋 + 吸管",
                        "seller_id": null,
                        "spec_name": "Fee Gift",
                        "sku_id": null,
                        "big": null,
                        "small": null,
                        "thumbnail": null,
                        "tiny": null,
                        "spec_type": null,
                        "spec_image": "",
                        "spec_value_id": 10262
                    }
                ],
                "point": null,
                "snapshot_id": 2866,
                "service_status": "NOT_APPLY",
                "single_list": [],
                "group_list": [],
                "goods_operate_allowable_vo": {
                    "allow_apply_service": false
                },
                "promotion_tags": [],
                "purchase_num": 0,
                "actual_pay_total": 2200,
                "actual_pay_total_list": null,
                "units_number": 25,
                "total_number": 125,
                "sn": null,
                "enable_quantity": null,
                "traits": false,
                "traits_name": null
            }
        ]
    },
    {
        "express_sn": "a5bmall15787268454",
        "express_name": "商城快递",
        "send_list": [
            {
                "item_id": null,
                "seller_id": 64,
                "seller_name": "全广州最靓的店",
                "goods_id": 8475,
                "sku_id": 25149,
                "sku_sn": "ABC005",
                "cat_id": 698,
                "num": 5,
                "goods_weight": 1.2,
                "original_price": 24,
                "original_price_list": {
                    "price_rmb": 24,
                    "price_myr": 14.2,
                    "price_thb": 102.86,
                    "price_idr": 47851.3,
                    "price_vnd": 79126.88,
                    "price_php": 172.17
                },
                "purchase_price": 24,
                "purchase_price_list": {
                    "price_rmb": 24,
                    "price_myr": 14.2,
                    "price_thb": 102.86,
                    "price_idr": 47851.3,
                    "price_vnd": 79126.88,
                    "price_php": 172.17
                },
                "subtotal": 2400,
                "subtotal_list": {
                    "price_rmb": 2400,
                    "price_myr": 1420.32,
                    "price_thb": 10286.4,
                    "price_idr": 4785129.6,
                    "price_vnd": 7912687.68,
                    "price_php": 17216.88
                },
                "name": "库存第二十一次测试",
                "goods_image": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/6
                "spec_list": [
                    {
                        "spec_id": 2659,
                        "spec_value": "粉红色",
                        "seller_id": null,
                        "spec_name": "Colour",
                        "sku_id": null,
                        "big": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\/D
                        "small": "http:\/\/47.88.173.86:82\/testShopImg\/20200109\
                        "thumbnail": "http:\/\/47.88.173.86:82\/testShopImg\/20200
                        "tiny": null,
                        "spec_type": 1,
                        "spec_image": "http:\/\/47.88.173.86:82\/testShopImg\/2020
                        "spec_value_id": 10260
                    },
                    {
                        "spec_id": 2660,
                        "spec_value": "800ml (1 套 = 20 件)",
                        "seller_id": null,
                        "spec_name": "Volume &amp; Pack",
                        "sku_id": null,
                        "big": null,
                        "small": null,
                        "thumbnail": null,
                        "tiny": null,
                        "spec_type": null,
                        "spec_image": "",
                        "spec_value_id": 10265
                    },
                    {
                        "spec_id": 2661,
                        "spec_value": "送白色布袋 + 吸管",
                        "seller_id": null,
                        "spec_name": "Fee Gift",
                        "sku_id": null,
                        "big": null,
                        "small": null,
                        "thumbnail": null,
                        "tiny": null,
                        "spec_type": null,
                        "spec_image": "",
                        "spec_value_id": 10262
                    }
                ],
                "point": null,
                "snapshot_id": 2867,
                "service_status": "NOT_APPLY",
                "single_list": [],
                "group_list": [],
                "goods_operate_allowable_vo": {
                    "allow_apply_service": false
                },
                "promotion_tags": [],
                "purchase_num": 0,
                "actual_pay_total": 2400,
                "actual_pay_total_list": null,
                "units_number": 25,
                "total_number": 125,
                "sn": null,
                "enable_quantity": null,
                "traits": false,
                "traits_name": null
            }
        ]
    }
],
"receipt_history": null,
"gift_list": [],
"cash_back": 0,
"cash_back_list": {
    "price_rmb": 0,
    "price_myr": 0,
    "price_thb": 0,
    "price_idr": 0,
    "price_vnd": 0,
    "price_php": 0
},
"coupon_price": 0,
"coupon_price_list": {
    "price_rmb": 0,
    "price_myr": 0,
    "price_thb": 0,
    "price_idr": 0,
    "price_vnd": 0,
    "price_php": 0
},
"gift_point": 0,
"gift_coupon": null,
"use_point": null,
"full_minus": 0,
"full_minus_list": {
    "price_rmb": 0,
    "price_myr": 0,
    "price_thb": 0,
    "price_idr": 0,
    "price_vnd": 0,
    "price_php": 0
},
"link_name": "mam",
"link_phone": "13554655555",
"license_add": "北坪仓库一号",
"shop_province": "马来西亚（Malaysia）",
"shop_city": "Kelantan",
"shop_county": "Ayer Lanas",
"shop_town": "",
"shop_add": "柯木塱",
"shop_name": "全广州最靓的店",
"ping_tuan_status": null,
"warehouse": {
    "id": 11,
    "house_name": "义乌仓",
    "country_id": "12",
    "house_type": "仓库",
    "link_tel": "15987536987",
    "link_man": "哆啦A梦",
    "post_code": "000000",
    "house_add": "义乌仓库",
    "wave_day": null,
    "wave_day_money": null,
    "lost_day": null,
    "jym": null,
    "sort": 5,
    "formula": null
},
"self_operated": 1
}
 */